"""BBS URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path
from app01 import views
from django.views.static import serve
from BBS import settings

urlpatterns = [
    path('admin/', admin.site.urls),
    path('register/', views.register, name='register'),
    path('login/', views.login, name='login'),
    path('get_code/', views.get_code, name='gc'),
    path('home/', views.home, name='home'),
    path('logout/', views.logout, name='logout'),
    path('set_password/', views.set_password, name='set_pwd'),

    # 后台管理
    path('backend/', views.backend, name='backend'),

    # 添加文章
    path('add/article', views.add_article, name='add_article'),

    # 编辑器上传图片
    path('upload_image/', views.upload_image, name='upload_image'),

    # 修改头像
    path('/set/avatar/', views.set_avatar, name='set_avatar'),

    # 暴露后端指定文件夹资源
    re_path(r'media/(?P<path>.*)', serve, {'document_root': settings.MEDIA_ROOT}, name='media'),

    # 点赞点踩
    path('up_and_down/', views.up_or_down, name='up_or_down'),
    path('comment/', views.comment, name='comment'),

    # 个人站点页面搭建
    re_path(r'^(?P<username>\w+)/$', views.site, name='site'),
    # 侧边栏筛选功能
    # re_path(r'^(?P<username>\w+)/categegory/(\d+)/', views.site),
    # re_path(r'^(?P<username>\w+)/tag/(\d+)/', views.site),
    # re_path(r'^(?P<username>\w+)/archive/(\w+)/', views.site),

    # 上面的三条url其实可以合并成一条
    re_path(r'^(?P<username>\w+)/(?P<condition>category|tag|archive)/(?P<param>.*)', views.site),

    # 文章详情页
    re_path(r'^(?P<username>\w+)/article/(?P<article_id>\d+)/', views.article_detail, name='article_detail'),

]
